from gaesessions import SessionMiddleware
#import os
import datetime

# suggestion: generate your own random key using os.urandom(64)
# WARNING: Make sure you run os.urandom(64) OFFLINE and copy/paste the output to
# this file.  If you use os.urandom() to *dynamically* generate your key at
# runtime then any existing sessions will become junk every time you start,
# deploy, or update your app!

#COOKIE_KEY = os.urandom(64)
COOKIE_KEY = ';"\xa9\xcdF\xe2\x03\x15\xdb\xde\xafX@\xfeY\\\x03\x99r\xab\xed&|\x12ZO\xc0oN\xe6\xa1\xd7)M`#\xcdu~39\xdf^\xba\x86\x82o\x0c\x8d\x1ad\xab<u\xe8\xbc\x15.\xd3\x8a\xcb=r\xdd'

def webapp_add_wsgi_middleware(app):
    #from google.appengine.ext.appstats import recording
    #app = SessionMiddleware(app, cookie_key=os.urandom(64))
    #app = recording.appstats_wsgi_middleware(app)
    app = SessionMiddleware(app, cookie_key=COOKIE_KEY, lifetime=datetime.timedelta(hours=2))
    return app